#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string ans;
  bool flag = true;
  if (n < 0) {
    flag = false;
  }
  n = abs(n);
  if (n == 0) {
    cout << 0;
    return 0;
  }
  while (n != 0) {
    int r = n % 3;
    if (r == 2) {
      ans = 'z' + ans;
      n = n / 3 + 1;
    } else {
      ans = to_string(r) + ans;
      n = n / 3;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    if (!flag) {
      if (ans[i] == 'z') {
        cout << 1;
      } else if (ans[i] == '1') {
        cout << 'z';
      } else {
        cout << 0;
      }
    } else {
      cout << ans[i];
    }
  }
  return 0;
}
